require('../css/motion.less')
const baseURL = require('../utils/baseURL.js')

window.onload = function () {
    common.footer('运动')



    let newCource = document.querySelector('.new-cource')
    let list = document.querySelector('.list')
    axios.get('/api/train/courseList').then(function (res) {
        let data = res.data.data
        console.log(data);
        newCource.innerHTML += `<a href="./courseInfo.html?id=${data[data.length - 1].courseId}">
                                <div class="title mt20">最新课程</div>
                                <div class="course1">
                                <img src="${baseURL + data[data.length - 1].imgurl}" alt="">
                                    <div class="cre">
                                        <div class="cre-title">${data[data.length - 1].name}</div>
                                        <div class="cre-text">${data[data.length - 1].desc}</div>
                                    </div>
                                </div>
                            </a>`

        let str = ``
        data.forEach(item => {
            str += `<a href="./courseInfo.html?id=${item.courseId}">
            <div class="course2">
            <img src="${baseURL + item.imgurl}" alt="">
                    <div class="cre2">
                        <div class="cre2-title">${item.name}</div>
                        <div class="cre2-text mt8">${item.desc}</div>
                    </div>
                </div>
                </a>`
        });
        list.innerHTML = str
    })
}